<?php
/**
Exibe um formul�rio para a altera��o de um setor j� cadastrado no banco de dados.
*/

if(!isset($_SESSION))
{
   session_start();
}

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

SAEO::ValidarAcesso( array( 0, 2 ) );

// Descri��es da Ajuda
$ajudaAno = 'showhint("Escolha o ano que a��o esta vinculado.", this, event, "220px");';
$ajudaPrograma = 'showhint("Escolha a a��o que deseja alterar.", this, event, "220px");';
$ajudacodResumido = 'showhint("C&oacute;digo resumido da a��o.", this, event, "220px");';
$ajudacodCompleto = 'showhint("C&oacute;digo completo da a��o.", this, event, "140px");';
$ajudaNomePrograma = 'showhint("Nome da a��o.", this, event, "140px");';

$ano = new Ano();
$anosCadastrados = $ano->CarregarAnos() # carrega do banco de dados todos os anos cadastrados e retorna o resultado em um array
?>
<html>
           <head>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           <title>SAEO - Alterar A&ccedil;&atilde;o Or&ccedil;ament&aacute;ria</title>
           
           <script type='text/javascript' src='templates/programa.js'></script>
           <script type='text/javascript' src='templates/hintbox.js'></script>
           <script type='text/javascript' src='templates/js.js'></script>
           <script type='text/javascript' src='templates/ajax.js'></script>
           <script type='text/javascript' src='templates/validacoes.js'></script>
           <link rel='stylesheet' type='text/css' href='templates/estilos.css'/>

           </head>
     <body class='body' onload="javascript: CarregarProgramas( document.alterar_Programa.anoId.value );">
     <form name='alterar_Programa' action='EnviarDadosPrograma.php?operacao=2' method='post' onsubmit='return ValidarAlterarPrograma();'>
     <table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
            <tr>
                <td colspan='2'><?php include "Topo.php"; ?></td>
            </tr>
            <tr>
                <td colspan='2'><div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>ALTERA&Ccedil;&Atilde;O DE A&Ccedil;&Atilde;O OR&Ccedil;AMENT&Aacute;RIA</div></td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
                <td colspan='2'><table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas' width='30%'>&nbsp;Ano:</td>
                               <td class='textoTabelas'>
                                   <select name='anoId' id='anoId' class='inputTexto'  onchange='EsconderDiv(getElementById("informacaoPrograma")); CarregarProgramas( this.value );' >
                                           <option value='0'>Selecione o Ano</option>
	                               			<?php
    		                           			$anoAtual = $ano->getAnoAtual(); 
					                            // Percorre o array anosCadastrados e cria options para cada posi��o.
			        		                    for ($i = 0; $i < count( $anosCadastrados ); $i++){
			                	            		$status = $anoAtual == $anosCadastrados[$i]->ano ? "selected" : "";
			                    	        		echo "<option value='".$anosCadastrados[$i]->id."' $status>".$anosCadastrados[$i]->ano."</option>";
			                        		    }
											?>
                                   </select>
                                   <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaAno ?>'>[?]</a>
                               </td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;A&ccedil;&atilde;o Or&ccedil;ament&aacute;ria: </td>
                               <td class='textoTabelas'>
                               <select style="width: 300px" name='programas' id='listaProgramas' class='inputTexto' onchange='MostrarDiv ( this.value, getElementById("informacaoPrograma")); CarregarPrograma(this.value);'>
                                       <option id='programa' value='0'>Primeiro selecione primeiro o Ano</option>
                               </select>
                               <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaPrograma ?>'>[?]</a>
                               </td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                            <tr>
                               <td colspan='2'>
                                   <div id='informacaoPrograma' style='display:none;'>
                                   <input type='hidden' name='programaId' id='programaId'>
                                   <table class='tabela' width='650' style='border-style: none' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                                        
                                          <tr>
                                              <td class='textoTabelas' width='30%'>&nbsp;C&oacute;digo Resumido: </td>
                                              <td class='textoTabelas'><input type='text' name='codResumido' id='codResumido' class='inputTexto'  size="10" maxlength="6" onKeyPress='return formataCampos(this,"??????", event);'> <a href='#' class='hintanchor' onMouseover='<?php echo $ajudacodResumido ?>'>[?]</a></td>
                                          </tr>                                          
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td class='textoTabelas' width='20%'>&nbsp;C&oacute;digo Completo: </td>
                                              <td class='textoTabelas'><input type='text' name='codCompleto' id='codCompleto' class='inputNumeros'  size="25" onKeyPress='return formataCampos(this,"??.???.????.????.????", event);'> <a href='#' class='hintanchor' onMouseover='<?php echo $ajudacodCompleto ?>'>[?]</a></td>
                                          </tr>
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td class='textoTabelas' width='30%'>&nbsp;Nome: </td>
                                              <td class='textoTabelas'><input type='text' name='nomePrograma' id='nomePrograma' class='inputTexto'  size="49" maxlength="200" "> <a href='#' class='hintanchor' onMouseover='<?php echo $ajudaNomePrograma ?>'>[?]</a></td>
                                          </tr>
                                                                                    
                                          <tr>
                                              <td colspan='2'>&nbsp;</td>
                                          </tr>
                                          <tr>
                                              <td colspan='2' height='46'><input type='image' style='width:100px;height:30px;position:relative;left:540px' src='templates/btavancar.JPG'/></td>
                                          </tr>
                                   </table>
                               </div>
                               </td>
                           </tr>
                     </table>
                </td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tfoot>
                   <tr>
                   		<td><?php include 'rodapeCreditos.php'; ?></td>
                   </tr>
            </tfoot>
     </table>
     </body>
     </html>
